﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Runtime.InteropServices;
using Heaven.Showcase.Demos;

namespace Heaven.Showcase
{
    /// <summary>
    /// Browser for demonstrations
    /// </summary>
	public partial class Browser
	{
        /// <summary>
        /// Constructor
        /// </summary>
		public Browser()
		{
            //Heaven.Xna.Graphics.WindowsPresentationDevice.ShowMonitor();
            Heaven.SlimDX.Graphics.WindowsPresentationDevice.ShowMonitor();

			this.InitializeComponent();

            comboBox.Items.Add("Select test...");
            comboBox.Items.Add("Test");
            comboBox.Items.Add("Procedural geometry sample");
            comboBox.Items.Add("Balls sample");
            //comboBox.Items.Add("Animation prtotype");
            
            comboBox.Items.Add("Textures sample");
            comboBox.Items.Add("Animations sample");
            comboBox.Items.Add("Multiple renders");
		}

        [DllImport("kernel32.dll")]
        public static extern bool SetProcessWorkingSetSize(IntPtr handle, int minimumWorkingSetSize, int maximumWorkingSetSize);


        void OnButtonClick(object sender, EventArgs e)
        {
            SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle,
                        -1, -1);
        }

        void OnForceGCClick(object sender, EventArgs e)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
        }

        private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            grid.Children.Clear();

            switch ((string)comboBox.SelectedItem)
            {
                case "Test":
                    grid.Children.Add(new Test());
                    break;
                case "Balls sample":
                    grid.Children.Add(new Balls());
                    break;
                case "Animation prtotype":
                    grid.Children.Add(new Prototype());
                    break;
                case "Animations sample": 
                    grid.Children.Add(new Animations());
                    break;
                case "Procedural geometry sample":
                    grid.Children.Add(new Construction());
                    break;
                case "Textures sample":
                    grid.Children.Add(new Textures());
                    break;
                case "Multiple renders":
                    
                    Prototype b = new Prototype();
                    b.Margin = new Thickness(200, 200, 200, 150);
                    grid.Children.Add(b);
                    Balls c = new Balls();
                    c.Margin = new Thickness(300, 300, 20, 20);
                    grid.Children.Add(c);
                    
                    Construction a = new Construction();
                    a.Margin = new Thickness(10, 10, 400, 200);
                    grid.Children.Add(a);
                   
                    
                    break;
            }
        }
	}
}
